import java.io.*;
import javax.bluetooth.*;
import javax.microedition.io.*;
import javax.obex.*;

public class serverbl extends ServerRequestHandler {
    String serviceURL = "btgoep://localhost:00B0D00154EF;name=DB_BT_OBEXServer";
    Connection clientConn = null;
    LocalDevice local_Device = null;
    
    public void runServer() {
       try {
          clientConn = Connector.open(serviceURL);
       }
       catch (IOException e) {
          System.exit(1);
       }
       try {
          local_Device = LocalDevice.getLocalDevice();
          local_Device.setDiscoverable(DiscoveryAgent.GIAC);
       }
       catch (BluetoothStateException e) {
          System.exit(1);
       }
       if (clientConn instanceof L2CAPConnectionNotifier) {
          L2CAPConnectionNotifier connListener = (L2CAPConnectionNotifier) clientConn;
          L2CAPConnection openConn = null;
          try {
             openConn = connListener.acceptAndOpen();
          }
          catch (IOException e) {
             System.err.println(e);
          }
       }
       else if (clientConn instanceof SessionNotifier) {
          SessionNotifier session = (SessionNotifier) clientConn;
          try {
             session.acceptAndOpen(this);
          }
          catch (IOException e) {
             System.err.println(e);
          }
       }
    }
    
	public static void main(String args[]) throws IOException
	{
		serverbl s = new serverbl();
		s.runServer();
	}
    
 }